package com.jingtai.platform.controller.merchants;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.merchants.UserStore;
import com.jingtai.platform.service.merchants.UserStoreService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 商户店铺表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:32
 */
@Validated
@RestController
@RequestMapping("/platform/userstore")
@Api(tags = "用户店铺表")
public class UserStoreController{

    @Autowired
    private UserStoreService userStoreService;


    @ApiOperation("商户店铺表列表查询")
    @GetMapping("/list")
    public ResultUtil aopUserStoreList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return userStoreService.UserStorelist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询userStore实体")
    @GetMapping("/getUserStoreById")
    public ResultUtil GetUserStoreById(@CApiParam(name = "id",value = "userStore实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return userStoreService.getUserStoreById(id);
    }

    @ApiOperation("根据用户群体查询userStore实体")
    @GetMapping("/getUserStoreByUserType")
    public ResultUtil GetUserStoreByUserType(@CApiParam(name = "userType",value = "userStore实体用户群体",required = true,cNotEmpty = true) @RequestParam("userType") Long userType){
        return userStoreService.getUserStoreByUserType(userType);
    }

    @ApiOperation("新增userStore实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"userStore.id","userStore.createTime","userStore.updateTime","userStore.deleteFlag"})
    public ResultUtil aopAddUserStore(@RequestBody @Validated({BaseEntity.Create.class}) UserStore userStore){
        return userStoreService.addUserStore(userStore);
    }

    @ApiOperation("编辑userStore实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"userStore.createTime","userStore.updateTime","userStore.deleteFlag"})
    public ResultUtil aopEditUserStore(@RequestBody @Validated({BaseEntity.Update.class}) UserStore userStore){
        return userStoreService.editUserStore(userStore);
    }

    @ApiOperation("根据ID删除userStore实体")
    @GetMapping("/delUserStoreById")
    public ResultUtil aopDelUserStoreById(@CApiParam(name = "id",value = "userStore实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return userStoreService.delUserStoreById(id);
    }

}






